class Solution {
public:
    vector<int> searchRange(vector<int>& nums, int target) {
        if (nums.size() == 0)
            return { -1,-1 };
        int left = 0;
        int right = nums.size() - 1;
        vector<int> v;
        while (left < right)
        {
            int min = left + (right - left) / 2;
            if (nums[min] < target)
            {
                left = min + 1;
            }
            else if (nums[min] >= target)
            {
                right = min;
            }
        }
        if (nums[right] == target)
        {
            v.push_back(right);
        }
        else
        {
            return { -1,-1 };
        }
        left = 0;
        right = nums.size() - 1;
        while (left < right)
        {
            int min = left + (right - left + 1) / 2;
            if (nums[min] <= target)
            {
                left = min;
            }
            else if (nums[min] > target)
            {
                right = min - 1;
            }
        }
        if (nums[left] == target)
        {
            v.push_back(left);
        }
        else
        {
            return { -1,-1 };
        }
        return v;
    }
};